package ru.amse.tsyganov.jumleditor.view;

import ru.amse.tsyganov.jumleditor.model.ActionState;
import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.Partition;
import ru.amse.tsyganov.jumleditor.model.StateVertex;
import ru.amse.tsyganov.jumleditor.model.SubactivityState;
import ru.amse.tsyganov.jumleditor.model.Transition;

public final class ViewElementFactory {
	public static final ViewElementFactory factory = new ViewElementFactory();
	
	private ViewElementFactory() {
	}
	
	public ActivityGraphView<ActivityGraph> createActivityGraphView() {
		ActivityGraph activityGraph = new ActivityGraph();
		ActivityGraphView<ActivityGraph> activityGraphView = 
			new ActivityGraphView<ActivityGraph>(activityGraph);
		
		ModelViewMap.map.getActivityGraphMap().put(activityGraph, activityGraphView);
		
		return activityGraphView;
	}
	
	public ActionStateView<ActionState> createActionStateView() {
		ActionState actionState = new ActionState();
		ActionStateView<ActionState> actionStateView = 
			new ActionStateView<ActionState>(actionState);
		
		ModelViewMap.map.getStatesMap().put(actionState, actionStateView);
		
		return actionStateView;
	}
	
	public PartitionView<Partition> createPartitionView() {
		Partition partition = new Partition();
		PartitionView<Partition> partitionView =
			new PartitionView<Partition>(partition);
		
		ModelViewMap.map.getPartitionsMap().put(partition, partitionView);
		
		return partitionView;
	}
	
	public SubactivityStateView<SubactivityState> createSubactivityStateView() {
		SubactivityState subactivityState = new SubactivityState();
		SubactivityStateView<SubactivityState> subactivityStateView = 
			new SubactivityStateView<SubactivityState>(subactivityState);
		
		ModelViewMap.map.getStatesMap().put(subactivityState, subactivityStateView);
		
		return subactivityStateView;
	}
	
	public TransitionView<Transition> createTransitionView(
			StateVertex sourceVertex, 
			StateVertex targetVertex) {
		
		Transition transition = new Transition(sourceVertex, targetVertex);
		TransitionView<Transition> transitionView = 
			new TransitionView<Transition>(transition);
		
		ModelViewMap.map.getTransitionsMap().put(transition, transitionView);
		
		return transitionView;
	}
}
